//
//  UITextField+Extension.m
//  FlatterMovie
//
//  Created by dongshangtong on 15/9/23.
//  Copyright © 2015年 dongshangtong. All rights reserved.
//

#import "UITextField+Extension.h"

@implementation UITextField (Extension)


/**
 *设置左边距离
 */
//-(void)setPaddingLeft:(CGFloat)leftSize
//{
//    CGRect frame = [self frame];
//    frame.size.width = leftSize;
//    UIView *leftview = [[UIView alloc] initWithFrame:frame];
//    self.leftViewMode = UITextFieldViewModeAlways;
//    self.leftView = leftview;
//    
//}
/**
 *设置图片左边距离
 */

-(void)setPaddingLeft:(CGFloat)leftSize Image:(NSString *)imageName
{
    
    CGRect frame = [self frame];
    frame.size.width =22+leftSize;
    UIView *leftview = [[UIView alloc] initWithFrame:frame];
    UIImage *img = [UIImage imageNamed:imageName];
    UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 8,22, 24)];
    imgView.image =img;
    self.leftView = leftview;
    self.leftViewMode = UITextFieldViewModeAlways;
    [leftview addSubview:imgView];
    
}

/**
 *设置右边距离
 */
-(void)setPaddingRight:(CGFloat)rightSize
{
    CGRect frame = [self frame];
    frame.size.width = rightSize;
    UIView *rightview = [[UIView alloc] initWithFrame:frame];
    self.rightViewMode = UITextFieldViewModeAlways;
    self.rightView = rightview;
    
}
/**
 *设置图片右边距离
 */

-(void)setPaddingRight:(CGFloat)rightSize Image:(NSString *)imageName
{
    CGRect frame = [self frame];
    frame.size.width =22+rightSize;
    UIView *rightView = [[UIView alloc] initWithFrame:frame];
    UIImage *img = [UIImage imageNamed:imageName];
    UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 8,22, 24)];
    imgView.image =img;
    self.rightView = rightView;
    self.rightViewMode = UITextFieldViewModeAlways;


    [rightView addSubview:imgView];
    
}


/**
 *  设置占位文字颜色
 */

-(void)setplaceholderLabel:(UIColor *)color font:(CGFloat )font
{
    
    
    [self setValue:color forKeyPath:@"_placeholderLabel.textColor"];
    [self setValue:[UIFont boldSystemFontOfSize:font] forKeyPath:@"_placeholderLabel.font"];
    
    
}

+ (void)setupColorWith:(NSArray *)textFieldArr
{
    for (UITextField * textField  in textFieldArr)
    {
        [textField setplaceholderLabel:[UIColor colorWithHexString:@"999999"] font: 14];
        textField.textColor = [UIColor colorWithHexString:@"999999"];
        textField.tintColor = [UIColor lightGrayColor];
    }
    
    
}


@end
